package ctn.convert;

import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;

import ctn.hibernate.po.CtnCpaInfo;
import ctn.hibernate.po.CtnCpaVer;
import ctn.service.dto.PlugDTO;
import ctn.util.StringUtils;

public class CPAVerCovert {
	private static DateFormat   df=new   SimpleDateFormat( "yyyy-MM-dd hh:mm"); 
	public static CtnCpaVer convertPo2VER(PlugDTO po,CtnCpaInfo cpa,CtnCpaVer ver){
		if(ver==null){
			ver=new CtnCpaVer();
		}
		if(po.getVerID()!=null){
			ver.setId(po.getVerID());
		}
		ver.setCtnCpaInfo(cpa);
		
			//if(!StringUtils.isEmptyString(po.getCompleteDate())){
				ver.setCompleteDate(po.getCompleteDate());
			//}
			//if(!StringUtils.isEmptyString(po.getEffDate())){
				ver.setEffDate(po.getEffDate());
			//}
			
		
//		ver.setFileName(po.getFileName());
//		ver.setProdFileName(po.getProdFileName());
		ver.setCtnGrpByImplGrpId(null);
		ver.setStatus(po.getVerStatus());
		if(StringUtils.isEmptyString(po.getVersion())){
			ver.setVersion("V1.0");
		}else{
			ver.setVersion(po.getVersion());
		}
		return ver;
	}
	public static PlugDTO convertVER2Po(CtnCpaVer ver,PlugDTO po){
		/*if(po==null){
			po=new CPAInfo();
		}*/
		po.setVerID(ver.getId());
		if(ver.getCompleteDate()!=null){
			po.setCompleteDate(ver.getCompleteDate());
		}
		if(ver.getEffDate()!=null){
			
			po.setEffDate(ver.getEffDate());
		}
//		po.setFileName(ver.getFileName());
//		po.setProdFileName(ver.getProdFileName());
		//po.setImplGrp(null);
		///
		po.setVersion(ver.getVersion());
		po.setVerStatus(ver.getStatus());
		//
		
		return po;
	}
}
